import config from "@/config"
import http from "@/utils/request"



export default {
  //登录时获取侧边用户菜单
  getMenus: {
    url: `${config.API_URL}/admin/getAdminInfo`,
    name: "获取用户菜单列表",
    get: function () {
      return new Promise((resolve, reject) => {
        http.get(this.url).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getAdminInfo: {
    url: `${config.API_URL}/admin/info`,
    name: "获取用户基本信息",
    get: function () {
      return new Promise((resolve, reject) => {
        http.get(this.url).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  // 用户管理 ---------------
  getUserList: {
    url: `${config.API_URL}/admin/list`,
    name: "获取用户列表",//无权限
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getAdminList: {
    url: `${config.API_URL}/admin/adminList`,
    name: "获取用户列表",//有权限
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  addUser: {
    url: `${config.API_URL}/admin/add`,
    name: "添加用户",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  updateUserInfo: {
    url: `${config.API_URL}/admin/update`,
    name: "修改用户信息",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  deleteUser: {
    url: `${config.API_URL}/admin/delete`,
    name: "删除用户",
    get: function (params) {
      return new Promise((resolve, reject) => {
        http.get(this.url, params).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deleteUserList: {
    url: `${config.API_URL}/admin/deleteList`,
    name: "批量删除用户",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  changeUserState: {
    url: `${config.API_URL}/admin/changeState`,
    name: "修改用状态",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  resetPassword: {
    url: `${config.API_URL}/admin/reset`,
    name: "重置用户密码",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  updatePassword: {
    url: `${config.API_URL}/admin/changePassword`,
    name: "修改用户密码",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  // 日志管理
  getLogList: {
    url: `${config.API_URL}/operationLog/page`,
    name: "获取日志管理列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  // 用户行动轨迹
  getUserSiteList: {
    url: `${config.API_URL}/site/list`,
    name: "获取所有用户行动轨迹列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },


}
